package cdu.javaendwork.service.Impl.AdoptionMore;

import cdu.javaendwork.dao.Universal;
import cdu.javaendwork.dao.impl.UniversalImpl;
import cdu.javaendwork.model.sqlModel.Remark;
import cdu.javaendwork.service.Interface.AdoptionMore.RemarkService;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class RemarkServiceImpl implements RemarkService {
    Universal universal = new UniversalImpl();

    @Override
    public boolean insert(int userid , int postid , String content , Date date) {
        int remark = universal.insert("Remark", userid, postid, content, date);
        return remark == 1;
    }

    @Override
    public boolean deleteById(int id) {
        return universal.deleteById("Remark", id) == 1;
    }

    @Override
    public Remark findById(int id) {
        return universal.getById("Remark",id);
    }

    @Override
    public List<Remark> limitByPostId(int postid, int pageIndex, int pageSize) {
        List<Remark> remarks = new ArrayList<>();
        remarks =  universal.filterLimit("Remark","postid="+postid,pageIndex,pageSize);
        return remarks;
    }
}
